const webpack = require('webpack');
const path = require('path');

//将模板加载bundle
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//指定webpack-dev-server运行的url 端口只能是8080
const OpenBroswerWebpackPlugin = require('open-browser-webpack-plugin');

module.exports = {
    entry: ['webpack/hot/dev-server', path.resolve(__dirname, 'app/main.js')],
    output: {
        path: path.resolve(__dirname, './build'),
        filename: '[name].js'
    },
    module: {
        loaders: [{
            test: /\.jsx?$/,
            include: [
                path.join(__dirname, './app'),
                path.resolve(__dirname, "./node_modules/amazeui-touch/js")
            ],
            loader: 'babel?presets[]=es2015-loose&presets[]=react'
        }, {
            test: /\.css$/,
            loader: 'style!css',
            exclude: '/(node_modules)/'
        }, {
            test: /\.scss$/,
            // loader: ExtractTextPlugin.extract('style', 'css!sass')
            loader: 'style!css!sass'
        }, {
            test: /\.(png|jpg|gif)$/,
            loader: 'url-loader?limit=4096'
        }, {
            test: /\.(ttf|woff|woff2|svg|eot)$/,
            loader: 'file-loader?name=fonts/[name].[ext]',
            exclude: '/(node_modules)/'
        }]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'html-withimg-loader!./index.html',
            filename: 'index.html'
        }),
        // new ExtractTextPlugin('style.css'),
        new OpenBroswerWebpackPlugin({
            url: 'http://localhost:8080'
        })
    ]
};